﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true" CodeFile="Categories.aspx.cs" Inherits="Admin_Categories" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:SqlDataSource ID="_SDSCategories" runat="server" 
    ConflictDetection="CompareAllValues" 
    ConnectionString="<%$ ConnectionStrings:DB_BookStoreConnectionString %>" 
    DeleteCommand="DELETE FROM [Categories] WHERE [CategoryID] = @original_CategoryID AND [CategoryName] = @original_CategoryName AND (([Description] = @original_Description) OR ([Description] IS NULL AND @original_Description IS NULL))" 
    InsertCommand="INSERT INTO [Categories] ([CategoryName], [Description]) VALUES (@CategoryName, @Description)" 
    OldValuesParameterFormatString="original_{0}" 
    SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]" 
    
    UpdateCommand="UPDATE [Categories] SET [CategoryName] = @CategoryName, [Description] = @Description WHERE [CategoryID] = @original_CategoryID AND [CategoryName] = @original_CategoryName AND (([Description] = @original_Description) OR ([Description] IS NULL AND @original_Description IS NULL))" 
    ProviderName="System.Data.SqlClient">
    <DeleteParameters>
        <asp:Parameter Name="original_CategoryID" Type="Int32" />
        <asp:Parameter Name="original_CategoryName" Type="String" />
        <asp:Parameter Name="original_Description" Type="String" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="CategoryName" Type="String" />
        <asp:Parameter Name="Description" Type="String" />
        <asp:Parameter Name="original_CategoryID" Type="Int32" />
        <asp:Parameter Name="original_CategoryName" Type="String" />
        <asp:Parameter Name="original_Description" Type="String" />
    </UpdateParameters>
    <InsertParameters>
        <asp:Parameter Name="CategoryName" Type="String" />
        <asp:Parameter Name="Description" Type="String" />
    </InsertParameters>
</asp:SqlDataSource>
<div id="featured-post">
    <h2>Quản lý thông tin các thể loại sách</h2>
    <asp:GridView ID="_grdView" runat="server" AutoGenerateColumns="False" 
    DataKeyNames="CategoryID" DataSourceID="_SDSCategories" AllowPaging="True" 
        CellPadding="4" ForeColor="#333333" GridLines="None" 
        onrowcommand="_grdView_RowCommand">
    <RowStyle BackColor="#EFF3FB" />
    <Columns>
        <asp:TemplateField ShowHeader="False">
            <EditItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                    CommandName="Update" Text="Update"></asp:LinkButton>
                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                    CommandName="Cancel" Text="Cancel"></asp:LinkButton>
            </EditItemTemplate>
            <ItemTemplate>
                &nbsp;<asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="False" 
                    CommandName="Delete" onclientclick="return confirm ('Delete?');" Text="Delete"></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" 
            InsertVisible="False" ReadOnly="True" SortExpression="CategoryID" />
        <asp:TemplateField HeaderText="CategoryName" SortExpression="CategoryName">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryName") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton11" runat="server" 
                    CommandArgument='<%# Bind("CategoryID") %>' CommandName="Edit" 
                    Text='<%# Bind("CategoryName") %>'></asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Description" HeaderText="Description" 
            SortExpression="Description" />
    </Columns>
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <EmptyDataTemplate>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
            CellPadding="4" DataKeyNames="CategoryID" DataSourceID="_SDSCategories" 
            DefaultMode="Insert" Height="50px" Width="125px" BackColor="White" 
            BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" 
            onitemcommand="DetailsView1_ItemCommand">
            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
            <RowStyle BackColor="White" ForeColor="#003399" />
            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
            <Fields>
                <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="CategoryID" />
                <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" 
                    SortExpression="CategoryName" />
                <asp:BoundField DataField="Description" HeaderText="Description" 
                    SortExpression="Description" />
                <asp:TemplateField ShowHeader="False">
                    <InsertItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                            CommandName="Insert" Text="Insert"></asp:LinkButton>
                        &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                            CommandName="Cancel" PostBackUrl="~/Admin/Categories.aspx" Text="Cancel"></asp:LinkButton>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                            CommandName="New" Text="New"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Fields>
            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
            <EditRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
        </asp:DetailsView>
    </EmptyDataTemplate>
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <EditRowStyle BackColor="#2461BF" />
    <AlternatingRowStyle BackColor="White" />
</asp:GridView>
    <asp:LinkButton ID="LinkButton10" runat="server" CommandName="New" PostBackUrl="~/Admin/Categories.aspx?action=insert" > Insert </asp:LinkButton>
</div><!--End .#featured-post-->
</asp:Content>

